<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="/common/commonCss.jsp" />
<jsp:include page="/common/commonJs.jsp" />
<script type="text/javascript" src="${basePath }commonJs/verify.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#branIdSelect option[value='${branId}']").attr("selected",true);
		refreshSelect();
		$("#fkBranId").val("${branId}");
		initTab("stockListform");
	});

	function initTab(formId) {
		
		var pkInstgId =$.trim($("#pkInstgId").val());
		$("#pkInstgIdSearch").val(pkInstgId);
		var form = $("#" + formId);
		var pagenbean = new PageBean(form);
		pagenbean.setTableId("stockListTable");
		pagenbean.setCallback(initTable);
		pagenbean.setFootId("stockListFoot");
		setPagebeanObj(pagenbean);
		pagenbean.doPage();
	}
	function initTable(data) {
		if (data == null) {
			return;
		}
		var verify = isVerify("${basePath }", "stock:delete1");
		trimJsonArray(data); 
		$.each(data, function(ind, obj) {
			var i = ind + 1;
			var date;
			var time;
			if(obj.modiTime != null &&  obj.modiTime != "")
				{
					date = new Date(obj.modiTime);
					time = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
				}else
				{
					time = "";
				}
			var instgId = obj.pkInstgId;
			var htm = "<tr>";
			htm += "<td>" + i + "</td>";
			htm += "<td class='lv'><a href='selectScmInstg.shtml?pkInstgId="+instgId+"'>"+instgId+"</td>";
			htm += "<td>" + obj.attFile + "</td>";
			htm += "<td>" + time + "</td>";
			htm += "<td>" + obj.usrName + "</td>";
			if(verify)
				{
				htm += "<td><input type='button' class='btn_l' value='删除' onclick=\"delInStock(this);\" instgId="+instgId+"></td></tr>";
				}
			else
				{
				htm += "<td></td></tr>";
				}
			$("#stockListTable").find("tr:eq(" + ind + ")").after(htm);
		});
	}
	
	//入库单删除操作
	function delInStock(obj) 
	{
		$.messager.confirm('警告', $common_confirm_delete, function(r) {
			if (r) {
				var instgId = $(obj).attr("instgId");
				$.ajax({
					url:"${basePath}StockGoodsIn/rollBackForStockIn.shtml",
					data:{"fkInstgId":instgId},
					dataType:"text",
					type:"post",
					async:false,
					success:function (result)
					{
						if(result == 1)
						{
							alertInfo($common_delete_success);
							initTab("stockListform");
						}
						if(result == 0)
						{
							alertError($common_delete_failure);
						}
					},
					error : function(XMLHttpRequest) {
						ajaxError(XMLHttpRequest);
					}
				});	
			}
		});
	}
	
	//设置pageNo为1
	function select1(formId){
		$("#"+formId+ " input:hidden[name='pageNo']").val(1);
		initTab(formId);
	}
	
	//跟换门店
	function branSelectFun() {
		$("#fkBranId").val($("#branIdSelect").val());
	}
</script>
<title>嘉童游乐中心-商品入库</title>
</head>
<body class="bg">
	<div class="content m_auto">
		<div class="content_l mt10">
			<ul>
				<shiro:hasPermission name="StockGoodsIn/toStock_goodsIn.shtml">
					<li class="content_hover"><a href="${basePath}StockGoodsIn/toStock_goodsIn.shtml"><i class="nav_icon_b"></i><br>商品入库</a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="StockQuery/toStockQuery.shtml">
					<li><a href="${basePath}StockQuery/toStockQuery.shtml"><i class="nav_icon_b"></i><br>库存查询</a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="StockGoodsOut/toStockGoodsOut.shtml">
					<li><a href="${basePath}StockGoodsOut/toStockGoodsOut.shtml"><i class="nav_icon_b"></i><br>商品出库</a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="StockTaking/toStockTaking.shtml">
					<li><a href="${basePath}StockTaking/toStockTaking.shtml"><i class="nav_icon_a"></i><br>库存盘点</a></li>
				</shiro:hasPermission>
				<shiro:hasPermission name="StockCorrect/toStockCorrect.shtml">
					<li><a href="${basePath}StockCorrect/toStockCorrect.shtml"><i class="nav_icon_f"></i><br>库存调整</a></li>
				</shiro:hasPermission>
			</ul>
		</div>
		<div class="content_r mt10">
			<div class="p20">
				<div class="file_single_dl f14 fixed">
					<dl class="fixed" style="overflow: hidden">
						<dd>
							<label>入库单号：</label><input type="text" class="iput_t w200"
								id="pkInstgId">
						</dd>
						<dd><label>所属门店：</label>
	                		<!----select--->
	                  	 	<div class="uboxstyle">
	                        	<select name="branIdSelect" id="branIdSelect" onchange="branSelectFun();">
	                        		<c:forEach items="${branList}" var="bran">
	                        			<option value="${bran.pkBranId}">${bran.branName}</option>
	                        		</c:forEach>
	                        	</select>
	                   		 </div>
	                   		 <!----select--->
                 		</dd>
						<dd>
							<input type="button" class="btn ml10" value="查询" onclick="select1('stockListform')">
							<shiro:hasPermission name="stock:add1">
							<input class="btn ml10" type="button" onclick="javascript:window.location.href='${basePath}StockGoodsIn/toStockAddGoodsIn.shtml'" value="新增入库">
							</shiro:hasPermission>
						</dd>
					</dl>
				</div>
				<form action="${basePath}StockGoodsIn/findScmInStg.shtml" method="post" id="stockListform">
					<input type="hidden" name="pageNo" value="1"> 
					<input type="hidden" name="pageSize" value="10"> 
					<input type="hidden" name="pkInstgId" id="pkInstgIdSearch">
					<input type="hidden" name="fkBranId" id="fkBranId">
				</form>
				<table class="table" id="stockListTable">
					<tr>
						<th>序号</th>
						<th>入库单编号</th>
						<th>入库单附件</th>
						<th>入库日期</th>
						<th>入库操作人</th>
						<th>操作</th>
					</tr>
				</table>
				<!----翻页----->
				<div class="page fr m10" id="stockListFoot"></div>
				<!----翻页----->
			</div>
		</div>
	</div>
</body>
</html>